/*
 * Copyright (C) 2016 The Android Open Source Project
 *  Created by  Ant  2016/9/30  13:34
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.ant.birds.beans;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;

import com.ant.birds.R;

/**
 * Created by baichuan on 2016/9/30.
 */
public class FloorBean {
    private int x, y, height, width;

    private Resources resources;
    private Bitmap floorBga, floorBgb;
    private boolean isb1 = true;

    private int[] bgs = {R.drawable.d1, R.drawable.d2};


    public FloorBean(Resources resources, int width, int height) {
        this.resources = resources;
        this.width = width;
        this.height = height;
        floorBga = BitmapFactory.decodeResource(this.resources, bgs[0]);
        floorBgb = BitmapFactory.decodeResource(this.resources, bgs[1]);

        initview();
    }


    private void initview() {
        floorBga = Bitmap.createScaledBitmap(floorBga, width, height, false);
        floorBgb = Bitmap.createScaledBitmap(floorBgb, width, height, false);
    }

    public void drawMe(Canvas canvas) {
        if (isb1) {
            canvas.drawBitmap(floorBga, x, y, null);
        } else {
            canvas.drawBitmap(floorBgb, x, y, null);
        }
        isb1 = !isb1;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }
}
